<?php
/**
 * This file is part of the Agora distribution. 
 * Detailed copyright and licensing information can be found
 * in the gpl-3.0.txt file which should be included in the distribution.
 * 
 * @version		$Id: 3.0.14 Olympus 2010-09-28 rammstein4o $
 * @copyright  2007 - 2010 jVitals
 * @license   GPLv3 Open Source
 * @link       http://jvitals.com
 * @since      File available since initial release
 */
 defined ('IN_AGORA') or die;
	class AgoraGroupsModel extends Model
	{
		function __construct()
		{
			parent::__construct('');
		}

		function isInstalled()
		{
			$this->db->setQuery('SHOW TABLES LIKE \'#__agoragroups\'');
			return $this->db->loadResult() ? true : false;
		}

		function getUserGroups($user_id)
		{
			$this->db->bind('user_id',$user_id,'integer');
			$this->db->setQuery('SELECT g.id,g.name FROM ##__group AS g'.
							' INNER JOIN ##__user_group AS ug'.
							'  ON ug.group_id = g.id'.
							' INNER JOIN #__agoragroups AS ag'.
							'  ON ag.group_id = g.id'.
							' WHERE ug.user_id = :user_id');
			return $this->db->loadAssocList();
		}
	}

?>
